<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide class="swiperSlide" v-for="item in swiperList" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination', // 分页样式
        loop: true // 复制多份循环(这里就是让轮播看起来是循环的，去掉这个就恢复了默认的swiper轮播)
      }
    }
  },
  computed: {
    showSwiper () {
      return this.swiperList.length
    }
  },
  props: {
    swiperList: Array
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background :#fff
  .wrapper
    height :0
    overflow :hidden
    padding-bottom :26.7%
    .swiperSlide
      .swiper-img
        width :100%
</style>
